Bokeh Tutorial

1.1 Charts - Timeseries

Exercise: Visualize the evolution of the temperature anomaly monthly average over time with a timeseries chart

  • Data: 'data/Land_Ocean_Monthly_Anomaly_Average.csv'

Tips:

import pandas as pd
pd.read_csv()
pd.to_datetime()

In [ ]:
import pandas as pd
from bokeh.charts import TimeSeries, output_notebook, show

In [ ]:
output_notebook()

In [ ]:
# Get data
be = pd.read_csv('data/Land_Ocean_Monthly_Anomaly_Average.csv',
                parse_dates=[0])

In [ ]:
be.head()

In [ ]:
be.datetime[:10]

In [ ]:
# Process data
be.datetime = pd.to_datetime(be.datetime)
be = be[['anomaly','datetime']]

In [ ]:
# Output option
output_notebook()

In [ ]:
# Create timeseries chart
t = TimeSeries(be, x='datetime', y='anomaly')

In [ ]:
# Show chart
show(t)

Exercise: Style your plot

Ideas:

  • Add a title
  • Add axis labels
  • Change width and height
  • Deactivate toolbox or customize available tools
  • Change line color

Charts arguments can be found: http://bokeh.pydata.org/en/latest/docs/user_guide/charts.html#generic-arguments


In [ ]:
# Style your timeseries chart

In [ ]:
# Show new chart

Exercise: Add the moving annual average to your chart

Tips:

pd.rolling_mean()

In [ ]:
# Compute moving average

In [ ]:
# Create chart with moving average

In [ ]:
# Show chart with moving average